package cn.iocoder.yudao.module.resource.dal.mysql.roletextaudio;


import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.resource.controller.admin.audiotext.vo.RoleTextAudioPageReqVO;
import cn.iocoder.yudao.module.resource.dal.dataobject.roletextaudio.RoleTextAudioDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 文本生成角色音频数据 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface RoleTextAudioMapper extends BaseMapperX<RoleTextAudioDO> {

    default PageResult<RoleTextAudioDO> selectPage(RoleTextAudioPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<RoleTextAudioDO>()
                .eqIfPresent(RoleTextAudioDO::getAudioTextId, reqVO.getAudioTextId())
                .orderByDesc(RoleTextAudioDO::getCreateTime));
    }

    default List<RoleTextAudioDO> getRoleTextAudio(List<Integer> roleIds, List<Integer> textIds) {
        LambdaQueryWrapperX<RoleTextAudioDO> queryWrapperX = new LambdaQueryWrapperX<>();
        queryWrapperX.in(RoleTextAudioDO::getAudioToneId, roleIds)
                .in(RoleTextAudioDO::getAudioTextId, textIds);
        return this.selectList(queryWrapperX);
    }

    default void setDeletedBatch(List<Integer> ids) {
        this.deleteBatchIds(ids);
    }

    default List<RoleTextAudioDO> getRoleTextForCreateAudio() {
        LambdaQueryWrapperX<RoleTextAudioDO> queryWrapperX = new LambdaQueryWrapperX<>();
        queryWrapperX.eq(RoleTextAudioDO::getStatus, 0);
        return selectList(queryWrapperX);
    }

}